import os
import random
import time

GITLAB_TOKEN = "2V8bFKMFTFzeGbbo72Ls"
GITLAB_URL = "http://gitlab.iwhalecloud.com/cloud/zcm-cloudtest-library.git"
CURRENT_WORK_DIR = os.path.abspath(os.path.join(os.getcwd(), ".."))  # 当前文件所在的目录
GITLAB_DIR = os.path.join(CURRENT_WORK_DIR, "library")
GITEA_DIR = os.path.join(CURRENT_WORK_DIR, "code")

# ZCM-portal所内域名
ZCM_PORTAL_ROOT_URL = "https://dev.iwhalecloud.com/"
# 发布流程调用启动robot任务测试接口
POST_URL = os.path.join(ZCM_PORTAL_ROOT_URL, "portal/zcm-cloudtest/autotestProjectInstance/triggerAutotestWithParams")
# 查询任务执行状态接口
GET_URL = os.path.join(ZCM_PORTAL_ROOT_URL, "portal/zcm-cloudtest/autotestProjectInstance/{}/status")

# 根据projectId、组名、文件名获取配置文件内容
GET_CONFIGFILE_CONTENT_URL = "{root_url}portal/zcm-image/ZcmConfigController/qryFileByCondition/{project_id}?fileName={fileName}&groupName={groupName}"
# 根据租户、项目名获取projectId
GET_PROJECT_ID_URL = "{root_url}portal/zcm-cmdb/rpc/project/tenantName/projectName?tenantName={tenantName}&projectName={projectName}"
# 根据projectId获取所有组信息
SELECT_CONFIG_GROUP = "{root_url}portal/zcm-image/ZcmConfigController/selectZcmConfigGroup?projectId={projectId}"
# 根据groupid获取该组下面所有文件信息
SELECT_CONFIG_FILE = "{root_url}portal/zcm-image/ZcmConfigController/selectZcmConfigFile?groupId={groupId}"
# 根据fileId获取配置文件内容
GET_CONFIG_FILE = "{root_url}portal/zcm-image/ZcmConfigController/getConfigFile/{file_id}"
# 扫描配置项全局忽略标识符
GLOBAL_IGNORE = "^*$"

# 接口请求成功code码
SUCCESS_CODE = '9999'
PWD_CHOICE = ["passwd", 'password', 'pwd']
PWD_RULE = "{cipher}{rsa}"
PWD_SUGGESTION = "使用安全的加密算法对密码进行加密"
PWD_NO_VALUE_SUGGESTION = "未设置密码，请设置"

HEADERS = {'X-CSRF-TOKEN': 'zcm', 'ZCM-Signature': 'nqaKCzL3ghK3sobCqzNRaFXhp6OFEOw5AYnxLijpR7I'}

# qmdb驱动包路径
jars_root_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "db_jars")
jars_dict = {
    "V9": os.path.join(jars_root_path, "qmdbjdbc-9.0.3-mdb.jar")
}
AVPFILE_STARTS_STRING = ["[", "{", "<"]
AVP_TYPE_MAP = {
    "OctStr": "OctetString",
    "UTF8Str": "UTF8String",
    "INT32": "Integer32",
    "Unsigned32": "Unsigned32",
    "UINT32": "Unsigned32",
    "INT64": "Integer64",
    "Unsigned64": "Unsigned64",
    "UINT64": "Unsigned64",
    "IPAddr": "IPAddress",
    "IP": "IP",
    "Time": "Time",
    "Grouped": "Grouped",
    "Enum": "Enumerated"
}

AVP_COMMAND_NAME_MAP = {
    "CCR": "Credit-Control"
}

DEFAULT_TASK_ID = int(time.time()) + random.randint(1, 99999)

# avp校验字段
NON_EXISTENT = "NON-EXISTENT"  # "该字段不能出现！"

ENV_ZCM_CODE_COV_COLLECT_MODE = 'ZCM_CODE_COV_COLLECT_MODE'
ENV_ZCM_CODE_COV_SINGLE_CASE_SWITCH = 'ZCM_CODE_COV_SWITCH'
HEADLESS_MODE = 'HEADLESS_MODE'
